package com.ne.alice;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ConnectionPerThreadWithPool implements Runnable{
    @Override
    public void run() {
        ExecutorService executor = Executors.newFixedThreadPool(100);
        try {
            ServerSocket serverSocket = new ServerSocket(8080);
            while(!Thread.interrupted()){
                Socket accept = serverSocket.accept();
                Handler handler = new Handler(accept);

            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static class Handler implements Runnable{

        final Socket socket;
        Handler(Socket s){
            socket = s;
        }
        @Override
        public void run() {
            boolean ioCompleted = false;
            while (!ioCompleted){
                try {
                    byte[] input = new byte[1024];
                    socket.getInputStream().read(input);
                    byte[] output = null;
                    socket.getOutputStream().write(output);
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
        }
    }
}
